package com.wedo.mall.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author lxy
 * @time 2017/7/22  11:48
 */
public final class DateUtils {

    /**时间戳转换：PHP后台返回时间戳是秒为单位，转为毫秒*/
    public static long convert(long origin){
        long to = origin * 1000;
        return to;
    }

    public static String convert(SimpleDateFormat format, long time){
        long to = convert(time);
        return format(format,to);
    }

    private static String format(SimpleDateFormat format,long time){
        return format.format(new Date(time));
    }

    public static String format(SimpleDateFormat format,String time){
        try {
            return format.format(new Date(Long.valueOf(time)));
        }catch (Exception e){
            e.printStackTrace();
            return time;
        }
    }
}
